home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wmv12s.zip / TESTMV.BAT < prev   
DOS Batch File  |  1993-01-04  |  8KB  |  313 lines

  1. echo off
  2. rem *** run this batch file if you suspect mv does not work properly on
  3. rem *** your system
  4. echo This batch file is used to test MV. Run in an empty directory.
  5. echo Make sure path points to MV.
  6. echo  
  7. if %2.==root. goto ok
  8. if %2.==notroot. goto ok
  9. goto noarg
  10. :ok
  11. echo > a
  12. if not exist %1:a goto userr
  13. pause
  14.  
  15. echo The DOS is
  16. ver
  17.  
  18. rem *** create files and directories to play with
  19. echo Creating files and sub-directories to test MV
  20. echo > b
  21. echo > c
  22. echo > e
  23. md f
  24. echo > f\x.x
  25. md g
  26. echo > g\y.y
  27.  
  28. rem *** test #1 - #19 exercise the "front" module
  29.  
  30. echo test#1 (file rename)
  31. rem *** should not cause any error
  32. mv e d > mv.log
  33. if errorlevel 1 goto err
  34. if exist e goto wrong
  35. if not exist d goto wrong
  36.  
  37. echo test#2 (sub-directory rename)
  38. rem *** should not cause any error
  39. mv f e > mv.log
  40. if errorlevel 1 goto err
  41. if exist f\x.x goto wrong
  42. if not exist e\x.x goto wrong
  43.  
  44. echo test#3 (try to rename file to another existing file)
  45. rem *** MV should detect error
  46. mv a b > mv.log
  47. if errorlevel 2 goto err
  48. if not errorlevel 1 goto noerr
  49. if not exist a goto wrong
  50.  
  51. echo test#4 (try to move multiple sources to a file name)
  52. rem *** MV should detect error
  53. mv * x. > mv.log
  54. if errorlevel 2 goto err
  55. if not errorlevel 1 goto noerr
  56. if exist x goto wrong
  57.  
  58. echo test#5 (similar to test#4)
  59. rem *** MV should detect error
  60. mv a b c > mv.log
  61. if errorlevel 2 goto err
  62. if not errorlevel 1 goto noerr
  63. if not exist a goto wrong
  64. if not exist b goto wrong
  65.  
  66. echo test#6 (try to move multiple source to a name)
  67. rem *** MV should detect error
  68. mv * x > mv.log
  69. if errorlevel 2 goto err
  70. if not errorlevel 1 goto noerr
  71. if exist x goto wrong
  72.  
  73. echo test#7 (try to move file into non-existing sub-directory)
  74. rem *** MV should detect error
  75. mv a f\. > mv.log
  76. if errorlevel 2 goto err
  77. if not errorlevel 1 goto noerr
  78. if not exist a goto wrong
  79.  
  80. echo test#8 (destination path not exist)
  81. rem *** MV should detect error
  82. mv a f\a > mv.log
  83. if errorlevel 2 goto err
  84. if not errorlevel 1 goto noerr
  85. if not exist a goto wrong
  86.  
  87. echo test#9 (destination path includes a file)
  88. rem *** MV should detect error
  89. mv a b\c > mv.log
  90. if errorlevel 2 goto err
  91. if not errorlevel 1 goto noerr
  92. if not exist a goto wrong
  93.  
  94. echo test#10 (destination specified as sub-directory but exists as a file)
  95. rem *** MV should detect error
  96. mv a b\. > mv.log
  97. if errorlevel 2 goto err
  98. if not errorlevel 1 goto noerr
  99. if not exist a goto wrong
  100.  
  101. echo test#11 (destination is ambigious)
  102. rem *** MV should detect error
  103. mv a * > mv.log
  104. if errorlevel 2 goto err
  105. if not errorlevel 1 goto noerr
  106. if not exist a goto wrong
  107.  
  108. echo test#12 (similar to test#11)
  109. rem *** MV should detect error
  110. mv a *\. > mv.log
  111. if errorlevel 2 goto err
  112. if not errorlevel 1 goto noerr
  113. if not exist a goto wrong
  114.  
  115. echo test#13 (rename file to itself)
  116. rem *** MV should detect error
  117. mv a . > mv.log
  118. if errorlevel 1 goto err
  119. if not exist a goto wrong
  120.  
  121. echo test#14 (source not exist)
  122. rem *** MV should detect error
  123. mv x y > mv.log
  124. if errorlevel 1 goto err
  125. if exist y goto wrong
  126.  
  127. echo test#15 (move files and sub-directory into sub-directory)
  128. rem *** no error
  129. mv *. e > mv.log
  130. if errorlevel 1 goto err
  131. if not exist e\a goto wrong
  132. if not exist e\b goto wrong
  133. if not exist e\c goto wrong
  134. if not exist e\d goto wrong
  135. if not exist e\g\y.y goto wrong
  136. if exist a goto wrong
  137. if exist b goto wrong
  138. if exist c goto wrong
  139. if exist d goto wrong
  140. if exist g\y.y goto wrong
  141.  
  142. echo test#16 (move sub-directory to current directory)
  143. rem *** no error
  144. mv e\g . > mv.log
  145. if errorlevel 1 goto err
  146. if not exist g\y.y goto wrong
  147. if exist e\g\y.y goto wrong
  148.  
  149. echo test#17 (move one sub-directory into another)
  150. rem *** no error
  151. mv e g > mv.log
  152. if errorlevel 1 goto err
  153. if not exist g\e\a goto wrong
  154. if exist e\a goto wrong
  155.  
  156. echo test#18 (move file to current directory)
  157. rem *** no error
  158. mv g\e\a .\a > mv.log
  159. if errorlevel 1 goto err
  160. if not exist a goto wrong
  161. if exist g\e\a goto wrong
  162.  
  163. echo test#19 (multiple sources with one missing source)
  164. mv g\e\a g\e\b g\e\* . > mv.log
  165. if errorlevel 1 goto err
  166. if not exist b goto wrong
  167. if not exist c goto wrong
  168. if not exist d goto wrong
  169.  
  170. rem *** the following tests exercise the "mv" module
  171.  
  172. echo test#20 (try to move current directory)
  173. rem *** should cause error
  174. mv . x > mv.log
  175. if errorlevel 2 goto err
  176. rem *** if current directory is root it'll cause errorlevel 1;
  177. if %2==root if not errorlevel 1 goto noerr
  178. rem *** otherwise no errorlevel
  179. if %2==notroot if errorlevel 1 goto err
  180.  
  181. echo test#21 (try to move parent into child)
  182. rem *** should cause error but no errorlevel
  183. mv g g\e > mv.log
  184. if errorlevel 1 goto err
  185. if not exist g\y.y goto wrong
  186.  
  187. echo test#22 (similar to test#21)
  188. mv g g\e\egg > mv.log
  189. if errorlevel 1 goto err
  190. if not exist g\y.y goto wrong
  191.  
  192. echo test#23 (similar to test#21)
  193. mv g g > mv.log
  194. if errorlevel 1 goto err
  195. if not exist g\y.y goto wrong
  196.  
  197. echo test#24 (try to move parent of current directory)
  198. mv .. g > mv.log
  199. rem *** depending on where you are, you either get
  200. rem *** "sorry, but root directory has no parent" (errorlevel 1) or
  201. rem *** "not moved to preserve current directory" (errorlevel 0) or
  202. rem *** "move root directory? You're joking" (errorlevel 1)
  203. if not exist a goto wrong
  204. if %2==root if not errorlevel 1 goto noerr
  205. rem *** if %2==notroot if errorlevel 1 goto err
  206.  
  207. rem ** the following tests exercise the "normal" module
  208.  
  209. echo test#25 (path includes drive letters but no root)
  210. mv %1:a %1:h > mv.log
  211. if errorlevel 1 goto err
  212. if not exist h goto wrong
  213. if exist a goto wrong
  214.  
  215. echo test#26 (path includes drive letters and root)
  216. mv %1:h %1:\i > mv.log
  217. if errorlevel 1 goto err
  218. if not exist \i goto wrong
  219. if exist h goto wrong
  220.  
  221. echo test#27 (path has upper case letters)
  222. mv %1:\I A > mv.log
  223. if errorlevel 1 goto err
  224. if not exist a goto wrong
  225. if exist %1:\i goto wrong
  226.  
  227. echo test#28 (missing sub-directory name before \..)
  228. mv a \\.. > mv.log
  229. if errorlevel 2 goto err
  230. if not errorlevel 1 goto noerr
  231. if not exist a goto wrong
  232.  
  233. echo test#29 (sub-directory name too long)
  234. mv a aaaaaaaaaaaaaaaaaaaaa > mv.log
  235. if errorlevel 2 goto err
  236. if not errorlevel 1 goto noerr
  237. if not exist a goto wrong
  238.  
  239. echo test#30 (referencing root's parent)
  240. mv a \.. > mv.log
  241. if errorlevel 2 goto err
  242. if not errorlevel 1 goto noerr
  243. if not exist a goto wrong
  244.  
  245. echo test#31 (.. not preceded by \)
  246. mv a .... > mv.log
  247. if errorlevel 2 goto err
  248. if not errorlevel 1 goto noerr
  249. if not exist a goto wrong
  250.  
  251. echo test#32 (source is "*\a\..")
  252. rem *** this is equal to mv g g which won't be performed
  253. mv *\a\.. g > mv.log
  254. if errorlevel 1 goto err
  255. if not exist a goto wrong
  256. if not exist g\y.y goto wrong
  257.  
  258. echo test#33 (no \ before .)
  259. mv %1:\g:.\y.y . > mv.log
  260. if errorlevel 2 goto err
  261. if not errorlevel 1 goto noerr
  262. if not exist g\y.y goto wrong
  263. if exist y.y goto wrong
  264.  
  265. echo MV passed all tests! Note the tests in here are not exhaustive.
  266. echo Now removing test files created awhile ago...
  267. del g\e\x.x > nul
  268. rd g\e > nul
  269. del g\y.y > nul
  270. rd g > nul
  271. del a > nul
  272. del b > nul
  273. del c > nul
  274. del d > nul
  275. del mv.log > nul
  276. goto dos
  277.  
  278. rem *** error handling routines
  279. :err
  280. echo MV reported an error that shouldn't happen:
  281. goto abort
  282.  
  283. :noerr
  284. echo MV failed to detect an error and did this:
  285. goto abort
  286.  
  287. :wrong
  288. echo MV performed an operation incorrectly:
  289. goto abort
  290.  
  291. :abort
  292. type mv.log
  293. echo Please report this problem to the author (type MV without parameters
  294. echo to get the author's email address).
  295. goto dos
  296.  
  297. :userr
  298. del a
  299. echo You have entered the incorrect parameters to testmv.
  300.  
  301. :noarg
  302. echo Usage: testmv [drv] [where]
  303. echo  
  304. echo   [drv] is the drive letter of the drive you're running testmv on (e.g
  305. echo      "A"). No quote, no colon.
  306. echo  
  307. echo   [where] is
  308. echo      "root" if you're running testmv in a root directory
  309. echo      "notroot" if you're running testmv in a sub-directory
  310. goto dos
  311.  
  312. :dos
  313.